﻿using Project_mfa.entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Project_mfa
{
    public partial class WebForm2 : System.Web.UI.Page
    {
        private Logging log;

        protected void Page_Load(object sender, EventArgs e)
        {
            log = new Logging();
            getBand(Request.QueryString["id"]);
        }

        protected void getBand(String id)
        {

            int selected = Convert.ToInt32(id);

            Data db = new Data();

            string ySearch = "";

            try
            {
                foreach (getBand_Result item in db.eGetBand(selected))
                {
                    ySearch = item.band_naam;
                    resultBand.Controls.Add(new LiteralControl("<div class='row'><div class='col col_16'><h1>" + item.band_naam + "</h1><br/></div></div>"));
                    resultBand.Controls.Add(new LiteralControl("<div class='row'><div class='col col_4'><a href='" + item.band_url + "'>" + item.band_url + "</a><br/><br/></div></div>"));
                    resultBand.Controls.Add(new LiteralControl("<div class='row'><div class='col col_16'>Genre: " + item.band_soortMuziek + "<br/></br></div></div>"));
                }

                resultBand.Controls.Add(new LiteralControl("<div class='row'><div class='col col_16'><h3>Gigs</h3><br/></div></div>"));
                resultBand.Controls.Add(new LiteralControl("<div class='row'><div class='col col_5'><strong>Festival</strong></div><div class='col col_5'><strong>Date</strong></div><div class='col col_5'><strong>Hour</strong></div><hr/></div>"));

                foreach (getBandFestivals_Result item in db.eGetBandFestivals(selected))
                {
                    resultBand.Controls.Add(new LiteralControl("<div class='row'><div class='col col_5'>"));

                    HyperLink festbtn = new HyperLink();
                    festbtn.Text = item.fest_naam;
                    festbtn.NavigateUrl = "Festival.aspx?id=" + item.fest_id;
                    resultBand.Controls.Add(festbtn);

                    resultBand.Controls.Add(new LiteralControl("</div><div class='col col_5'>" + item.datum + "</div>"));
                    resultBand.Controls.Add(new LiteralControl("<div class='col col_5'>" + item.uur + "</div></div>"));
                    resultBand.Controls.Add(new LiteralControl("<div class='row'><div class='col col_16'><hr/></div></div>"));
                }

                resultBand.Controls.Add(new LiteralControl("<div class='row'><div class='col col_16'><br/><h5>Youtube videos, click to play</h5><br/></div></div>"));
                resultBand.Controls.Add(new LiteralControl("<div class='row'><div class='col col_16'><div id='ytThumbs'></div></div></div>"));

                resultBand.Controls.Add(new LiteralControl("<script type='text/javascript'>"));
                resultBand.Controls.Add(new LiteralControl("$(document).ready(function() {"));
                resultBand.Controls.Add(new LiteralControl("ytEmbed.init({'block': 'ytThumbs', 'q': '" + ySearch + "', 'type': 'search', 'results': 8, 'order': 'most_relevance', 'player': 'embed', 'layout': 'thumbnails'});"));
                resultBand.Controls.Add(new LiteralControl(" });"));
                resultBand.Controls.Add(new LiteralControl(" </script>"));
            }
            catch (Exception e)
            {
                log.WriteLine("Band", e.Message);
            }
        }
    }
}